<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class DataLRAController extends BaseController {
    /*
     * Konstruktor
     */

    public function __construct($registry) {
        parent::__construct($registry);
    }

    /*
     * Index
     */

    public function index() {
        
    }

    public function DataLRA() {
        $d_spm1 = new DataLRA($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));
		
		if (isset($_POST['submit_file'])) {
			if ($_POST['tgl_awal'] != '' AND $_POST['tgl_akhir'] != '') {
					$filter[$no++] = "TO_CHAR(TGLPOST,'YYYYMMDD') BETWEEN '" . date('Ymd', strtotime($_POST['tgl_awal'])) . "' AND '" . date('Ymd', strtotime($_POST['tgl_akhir'])) . "'";

					$this->view->d_tgl_awal = $_POST['tgl_awal'];
					$this->view->d_tgl_akhir = $_POST['tgl_akhir'];
				}
			$this->view->data = $d_spm1->get_lra_harian($filter);
		}
		else {
			$this->view->data = $d_spm1->get_lra_apbn($filter);
		}
		$this->view->action = 'DataLRA';
		$d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());
		
        $this->view->render('baes1/LRA');
    }
	
	public function DataLRAYoY() {
        $d_spm1 = new DataLRA($this->registry);
        $filter = array();
		$filter2 = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));
		
		if (isset($_POST['submit_file'])) {
			if ($_POST['tgl_awal'] != '' AND $_POST['tgl_akhir'] != '') {
					$filter[$no++] = "TO_CHAR(TGLPOST,'MMDD') BETWEEN '" . date('md', strtotime($_POST['tgl_awal'])) . "' AND '" . date('md', strtotime($_POST['tgl_akhir'])) . "'";
					$filter2[$no++] = "TO_CHAR(TGLPOST,'MMDD') BETWEEN '" . date('md', strtotime($_POST['tgl_awal'])) . "' AND '" . date('md', strtotime($_POST['tgl_akhir'])) . "'";
					$this->view->d_tgl_awal = $_POST['tgl_awal'];
					$this->view->d_tgl_akhir = $_POST['tgl_akhir'];
				}
			$this->view->data = $d_spm1->get_lra_yoy($filter ,$filter2);
		}
		else {
			$this->view->data = $d_spm1->get_lra_yoy_non_filter($filter );
		}
		$d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());
		
        $this->view->render('baes1/LRAYoY');
    }
	
	public function DataLRASL() {
        $d_spm1 = new DataLRA($this->registry);
        $filter = array();
		$filter2 = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));
		
		
			$this->view->data = $d_spm1->get_lra_sub_modul($filter );
			$this->view->action = 'DataLRASL';
			$this->view->judul = 'Data Sub Ledger';
		$d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());
		
        $this->view->render('baes1/LRA');
    }

    

    public function __destruct() {
        
    }

}
